
// 基于axios 封装的接口请求文件 以及所有的请求接口
import axios from 'axios';

// 请求域名
let urlBase = 'http://vue.yaoyiwangluo.com'; 

axios.interceptors.request.use(function (config) {// 这里的config包含每次请求的内容
//   if (localStorage.getItem('GH_TOKEN')) {
//     config.headers.token = localStorage.getItem('GH_TOKEN');  //设置请求头
//   }
//   config.headers['Content-Type'] = 'application/json';  //设置请求头
  return config;
}, function (err) {
  return Promise.reject(err);
});

// post方法
export const postRequest = async (url, params) => {
  try {
    const res = await axios.post(`${urlBase}${url}`, params);
    return res;
  }
  catch (err) {
    return err;
  }
};
// get方法
export const getRequest = async (url, params) => {
  try {
    const res = await axios.get(`${urlBase}${url}`, params);
    return res;
  }
  catch (err) {
    return err;
  }
};

// 登录
export const authLogin = (params) => { return getRequest('/wx_check_login_yonghu.asp', params) };
// 注册
export const authReg= (params) => { return getRequest('/wx_check_reg_yonghu.asp', params) };
// 获取公告
export const getNews = (params) => { return getRequest('/wx_news_list.asp', params) };
// 获取公告详情
export const getNewsDetails = (params) => { return getRequest('/wx_news_info.asp', params) };
// 获取最新上架
export const getNewGoods = (params) => { return getRequest('/wx_CpList_top4.asp', params) };
// 获取精品推荐
export const getRecommendGoods = (params) => { return getRequest('/wx_CpList_tuijian4.asp', params) };
// 产品排序
export const rank = (params) => { return getRequest('/wx_CpList_paixu.asp', params) };
// 获取产品列表
export const getGoodsList = (params) => { return getRequest('/wx_CpList_tuijian6.asp', params) };
// 搜索产品列表
export const searchGoodsList = (params) => { return getRequest('/wx_CpList.asp', params) };
// 获取产品简介信息
export const getGoods = (params) => { return getRequest('/wx_sp_info-a.asp', params) };
// 获取产品详情
export const getGoodsDetails = (params) => { return getRequest('/wx_sp_info-b.asp', params) };
// 获取产品评论
export const getGoodsComments = (params) => { return getRequest('/wx_Pinlun_list_vue.asp', params) };
// 收藏
export const collectGoods = (params) => { return getRequest('/wx_shoucang_add.asp', params) };
// 加入购物车/购买
export const addShoppingCart = (params) => { return getRequest('/wx_gwc_add.asp', params) };
// 获取购物车列表
export const getshoppingCartList = (params) => { return getRequest('/wx_gwc_list.asp', params) };
// 保存商品数量
export const saveGoodsNum = (params) => { return getRequest('/wx_gwc_shuxiugai.asp', params) };
// 获取下单商品
export const getBuyGoods = (params) => { return getRequest('/wx_gwc_list_by_ids.asp', params) };
// 下单
export const toBuyGoods = (params) => { return getRequest('/wx_gwc_xiadan_by_cpids.asp', params) };
// 获取商品分类
export const getClassify = (params) => { return getRequest('/wx_fenlei.asp', params) };
// 获取分类内容
export const getClassifyInfo = (params) => { return getRequest('/wx_fenlei_chanpin.asp', params) };
// 获取用户信息
export const getUserInfo = (params) => { return getRequest('/wx_u_xinxi_duqu.asp', params) };
// 获取订单信息
export const getOrderInfo = (params) => { return getRequest('/wx_dingdan_list_by_lxid.asp', params) };
// 获取我的收藏
export const getMyFavorite = (params) => { return getRequest('/wx_shoucang_list.asp', params) };
// 删除我的收藏
export const delMyFavorite = (params) => { return getRequest('/wx_shoucang_del.asp', params) };
// 获取地址
export const getAdderss = (params) => { return getRequest('/wx_dizhi_list.asp', params) };
// 删除地址
export const delAdderss = (params) => { return getRequest('/wx_dizhi_Del.asp', params) };
// 添加地址
export const addAdderss = (params) => { return getRequest('/wx_dizhi_add.asp', params) };
// 头像上传
export const imgUpload = (params) => { return postRequest('/up/ajax_upload.asp', params) };
// 修改用户信息
export const uploadUserInfo = (params) => { return getRequest('/wx_u_xinxi_gengxin.asp', params) };
// 修改密码
export const uploadPwd = (params) => { return getRequest('/wx_check_mima_xiugai.asp', params) };
// 取消订单
export const cancelOrder = (params) => { return getRequest('/wx_dingdan_del.asp', params) };
// 付款
export const payment = (params) => { return getRequest('/wx_dingdan_fukuan.asp', params) };
// 确认收货
export const received = (params) => { return getRequest('/wx_dingdan_shouhuo.asp', params) };

















